package com.website.web.front.controller;

import com.website.common.core.controller.BaseController;
import com.website.custom.domain.*;
import com.website.custom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class IndexController extends BaseController {

    @Autowired
    private IWCarouselService wCarouselService;
    @Autowired
    private IWNoticeService wNoticeService;
    @Autowired
    private IWServicesService wServicesService;
    @Autowired
    private IWAboutService wAboutService;
    @Autowired
    private IWCaseService wCaseService;
    @Autowired
    private IWNewsService wNewsService;
    @Autowired
    private IWLinkService wLinkService;
    @Autowired
    private IWConfigService wConfigService;

    @GetMapping("/")
    public String index(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
        // 轮播图
        WCarousel wCarousel = new WCarousel();
        wCarousel.setwType(0);
        List<WCarousel> wCarousels = wCarouselService.selectWCarouselList(wCarousel);
        model.put("wCarousels", wCarousels);
        // 广播
        List<WNotice> wNotices = wNoticeService.selectWNoticeList(null);
        model.put("notices", wNotices);
        // 服务项目
        List<WServices> services = wServicesService.selectWServicesList(null);
        model.put("services", services);
        // 关于我们
        WAbout wAbout = wAboutService.selectWAboutById(1L);
        model.put("wAbout", wAbout);
        // 案例展示
        List<WCase> wCases = wCaseService.selectTopWCaseList();
        model.put("caseList", wCases);
        // 新闻中心
        List<WNews> wNews = wNewsService.selectTopWNewsList();
        model.put("newsList", wNews);
        // 获取友情链接列表
        List<WLink> wLinks = wLinkService.selectWLinkList(null);
        model.put("linkList", wLinks);
        WConfig wConfig = wConfigService.selectWConfigById(1l);
        model.put("wConfig",wConfig);
        return "front/index";
    }
}
